package com.lingz.manager.modules.wuxue.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lingz.manager.common.vo.PageVo;
import com.lingz.manager.common.utils.ResultUtil;
import com.lingz.manager.common.vo.Result;
import com.lingz.manager.modules.scheduled.NiuKangTask;
import com.lingz.manager.modules.wuxue.entity.DailyInsectCatchData;
import com.lingz.manager.modules.wuxue.service.DailyInsectCatchDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;
import java.util.List;

/**
 * @author caiyixun
 */
@Slf4j
@RestController
@Api(description = "纽康每日捕虫数数据管理接口")
@RequestMapping("/wuxue/dailyInsectCatchData")
@Transactional
public class DailyInsectCatchDataController {

    @Autowired
    private DailyInsectCatchDataService dailyInsectCatchDataService;

    @GetMapping("/findDailyInsectCatchDataList")
    @ApiOperation("不分页查询纽康每日捕虫数数据")
    public Result<List<DailyInsectCatchData>> findDailyInsectCatchDataList(DailyInsectCatchData dailyInsectCatchData) throws IOException {
//        NiuKangTask niuKangTask = new NiuKangTask();
//        niuKangTask.insertDailyInsectCatchData();
         return new ResultUtil<List<DailyInsectCatchData>>().setData(dailyInsectCatchDataService.findListDailyInsectCatchData(dailyInsectCatchData));
    }

     @GetMapping("/findDailyInsectCatchDataPage")
     @ApiOperation("分页查询纽康每日捕虫数数据")
     public Result<Page<DailyInsectCatchData>> findDailyInsectCatchDataPage(DailyInsectCatchData dailyInsectCatchData, PageVo pageVo){
         return new ResultUtil<Page<DailyInsectCatchData>>().setData(dailyInsectCatchDataService.findPageDailyInsectCatchData(dailyInsectCatchData,pageVo));
     }

     @PostMapping("/insertDailyInsectCatchData")
     @ApiOperation("新增纽康每日捕虫数数据")
     public Result<String> insertCaseInfo(DailyInsectCatchData dailyInsectCatchData){
         return new ResultUtil<String>().setData(dailyInsectCatchDataService.addDailyInsectCatchData(dailyInsectCatchData));
     }

     @PostMapping("/updateDailyInsectCatchData")
     @ApiOperation("修改纽康每日捕虫数数据")
     public Result<String> updateCaseInfo(DailyInsectCatchData dailyInsectCatchData){
         return new ResultUtil<String>().setData(dailyInsectCatchDataService.editDailyInsectCatchData(dailyInsectCatchData));
     }

     @DeleteMapping("/deleteDailyInsectCatchData")
     @ApiOperation("删除纽康每日捕虫数数据")
     public Result<String> deleteDailyInsectCatchData(String[] ids){
         return new ResultUtil<String>().setData(dailyInsectCatchDataService.deleteDailyInsectCatchData(ids));
     }

    @GetMapping("/findDailyInsectCatchDataById")
    @ApiOperation("获取一条信息")
    public Result<DailyInsectCatchData> findDailyInsectCatchDataById(String id){
        return new ResultUtil<DailyInsectCatchData>().setData(dailyInsectCatchDataService.findDailyInsectCatchDataById(id));
    }

}
